package com.lyf.scm.job.task;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.lyf.scm.job.config.AbstractSimpleJob;
import com.lyf.scm.job.remote.facade.BigDataStoreFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 大数据直营门店
 *
 * @author wangchlei
 * @date 2020/09/14
 */
@Slf4j
@Component
public class BigDataStoreJob extends AbstractSimpleJob {
    @Value("${elastic.job.bigDataStoreHandlerJob.jobName}")
    private String jobName;
    @Value("${elastic.job.bigDataStoreHandlerJob.cron}")
    private String cron;
    @Value("${elastic.job.bigDataStoreHandlerJob.shardingTotalCount}")
    private Integer shardingTotalCount;
    @Value("${elastic.job.bigDataStoreHandlerJob.shardingItemParameters}")
    private String shardingItemParameters;
    @Value("${elastic.job.bigDataStoreHandlerJob.failover}")
    private Boolean failover;
    @Value("${elastic.job.bigDataStoreHandlerJob.desc}")
    private String desc;

    @Resource
    private BigDataStoreFacade bigDataStoreFacade;

    /**
     * 处理
     *
     * @param shardingContext
     * @return void
     **/
    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("================== 开始执行大数据Job ==================");
        bigDataStoreFacade.handleApiDispatcher();
    }

    @Override
    public void run(String... args) {
        // spring 启动完成后初始化job
        registerSimpleJob(jobName, cron, shardingTotalCount, shardingItemParameters, failover, desc);
    }
}
